<?php namespace App\Api\Http\ApiControllers;

use Illuminate\Http\Request;

class WechatController extends Controller
{
    /**
     * 获取微信js sdk接口配置
     *
     * @param Request $request
     *
     * @return array|\Illuminate\Http\JsonResponse
     */
    public function config(Request $request)
    {
        $url = $request->get('url');

        /** @var \EasyWeChat\Js\Js $js */
        $js = app('wechat')->js;
        if (!$url && !url()->isValidUrl($url)) {
            return [];
        }
        $js->setUrl($url);
        $config = $js->config([
        	'chooseWXPay','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone','hideOptionMenu','showOptionMenu','hideMenuItems','showMenuItems'
        ], config('wechat.jssdk_debug'), false, false);

        return response()->json($config);
    }
}
